package cn.tedu.csmall.stock.webapi.service.impl;


import cn.tedu.csmall.commons.pojo.stock.dto.StockReduceCountDTO;
import cn.tedu.csmall.commons.pojo.stock.entity.Stock;
import cn.tedu.csmall.stock.service.IStockService;
import cn.tedu.csmall.stock.webapi.mapper.StockMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * @DubboService注解表示当前业务逻辑层实现类中的所有方法
 * 均会注册到Nacos,成为Dubbo可以被发现的业务逻辑层的方法
 *
 * stock-webapi是生产者模块  是Dubbo服务的生产者
 */
@DubboService
@Service
@Slf4j
public class StockServiceImpl implements IStockService {

    @Autowired
    private StockMapper stockMapper;

    @Override
    public void reduceCommodityCount(StockReduceCountDTO stockReduceCountDTO) {

        stockMapper.updateStockCountByCommodityCode(stockReduceCountDTO.getCommodityCode(),stockReduceCountDTO.getReduceCount());
        log.info("库存减少成功:{}",stockReduceCountDTO);
    }
}
